// JavaScript Document
var t1 = 0, t2 = "X";
var VatTu = kendo.data.Model.define({
		id: "id",
		fields:{
			"MaVT": {type: "string"},
			"TenVT": {type: "string"},
			"DVT": {type: "string"},
			"GiaGoc": {type: "number"},	
		},
	
	
	});

var v = new VatTu({
		MaVT: "V10016",
		TenVT: "Bột sắt d=10mm",
		DVT: "cái",
		GiaGoc: 2000,
		GiaThang: {
			Thang1: 1900,
			Thang2: 2101,	
		}
	
	});

var d = new kendo.data.DataSource({
	transport: {
		read: "dutoan/gia.php",	
	},
	schema: {
		model: VatTu,
	}
	
	});

var g;
function writesub(s)
{
	document.getElementById("subdiv").innerHTML = s;	
}
function writesup(s)
{
	document.getElementById("supdiv").innerHTML = s;	
}
function writemain(s)
{
	document.getElementById("maindiv").innerHTML = s;	
}
function handler(e)
{
	writesub(e.field);	
}
function test1()
{
	writesub("Test 1 Running ...");	
	alert(d.at(1).get("TenVT"));
}
function test2()
{
	//writesub("Test 2 Running ...");		
	t2+="x";	
	v.set("DVT", "Cái"+t2);
	document.getElementById("maindiv").innerHTML = v.get("DVT");
	
}

function test3()
{
	var vt = document.getElementById("txt").value;
	alert(vt);
	var location = "dutoan/gia.php";
	if (vt != "")
	{
		location = "dutoan/gia.php?mavt=" + vt;
	}
	$(function() {
	$("#grid").kendoGrid({
			dataSource: {
				transport: {
					read: location,	
				},
				schema: {
					data: "data",	
				},	
			},
			
			column: [{field: "MaVT"},{field: "TenVT"},{field: "DVT"},{field: "GiaGoc"}],
			
		});
	});
	
}

function test4()
{
	writesup("Test 3 Running ...");
	writemain(v.get("GiaThang.Thang2"));
}
